<?php
$this->pageTitle=Yii::app()->name . ' - 投票';
$this->breadcrumbs=array(
	'投票',
);
?>

<h1>投票：<?php echo CHtml::link($poll->node->title, array('/node/view', 'id'=>$poll->node->id)); ?></h1>
<div style = "border: 1px #333 solid;  padding: 10px; margin-bottom: 10px; ">
<?php
echo "投票类型：".HandleBox::getPollType($_GET['tid'])."<br />";
echo "投票值：".$poll->value."<br />";
echo "申请理由：";
echo $poll->description."<br />";
if ($poll->status == 1){
	echo "状态：正在进行中……";
}
else{
	echo "状态：已过期关闭";
}
?>
</div>
<?php
$total = 1;
$yes = 0;
$no = 0;
foreach ($pollVote as $vote){
	echo "<span style = 'background: #F7F7F7; padding: 5px; margin-right: 10px;'>".$total."</span>";
	if ($vote->value == 1){
		echo "<span style = 'background: #caf6bd; margin-right: 10px; padding: 2px 5px; '>支持</span>";
		$yes++;
	}
	else{
		echo "<span style = 'background: #f6bdbd; margin-right: 10px; padding: 2px 5px;'>反对</span>";
		$no++;
	}
	echo $vote->reason;
	echo "投票者：".CHtml::link($vote->user->username, array('user/view', 'id'=>$vote->user->id));
	echo "<br />";
	$total++;
}
?>
<br />
<?php
echo "<h3>统计</h3>";
echo "支持：".$yes."<br />";
echo "反对：".$no."<br />";
$score = $yes/($total-1);
echo "支持率：".sprintf('%.0f%%',$score*100)."<br />";

if ($poll->status == 0){
	if ($score > 0.66){
		echo "<div>结果：通过</div>";

	}
}
?>